<%@ page import="java.io.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*" %>
<%
String driver ="com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/projects";
String username = "ia";
String password = "123";
String id = request.getParameter("id");
String [] name = null;
String [] proj_id = null;
int size = 0;
try
{
	Class.forName(driver).newInstance();
	
	Connection connection = DriverManager.getConnection(url, username, password);
	
	Statement statement = connection.createStatement();
	Statement statement1 = connection.createStatement();
	String query = "select count(*) from student";
	String query1 = "select * from student";
	ResultSet rs = statement.executeQuery(query);
	ResultSet rs1 = statement1.executeQuery(query1);
	if(rs.next())
	{
		size = rs.getInt(1);
		name = new String[size];
		proj_id = new String[size];
	}
	
	for(int i=0;rs1.next();i++)
	{
		name[i] = rs1.getString("first_name") + " " + rs1.getString("last_name");
		proj_id[i] = rs1.getString("proj_id");
	}

	connection.close();
		
}catch(ClassNotFoundException cnfe)
{
		out.println("<br>Couldn't find class file" + cnfe); 
}catch(SQLException sqle)
{
		out.println("<br>SQL Exception: " + sqle);
}catch(InstantiationException ie)
{
		out.println("<br>Instant exception : " + ie);
}catch(IllegalAccessException iae)
{
		out.println("<br>Illegal access exception : " + iae);
}
%>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<link rel="STYLESHEET" href="styles/project.css" type="text/css">
</head>
<body>
<%
if(name == null || name.length < 1)
	out.println("There are no students joined to this project");
else {
%>
<table>
<%
boolean check = false;
for(int i=0;i<name.length;i++)
{
	if(proj_id[i].equals(id))
	{
%>
<tr>
<td>
name:
</td>
<td>
<%=name[i]%>
</td>
</tr>
<%
	check = true;
	}
}
if(!check)
	out.println("There are no students joined to this project");
%>
</table>
<%
}
%>
</body>
</html>